diff --git a/ext/user/main.php b/ext/user/main.php
index e3d124cd..de545a8f 100644
--- a/ext/user/main.php
+++ b/ext/user/main.php
@@ -494,27 +494,20 @@ class UserPage extends Extension {
 	private function user_can_edit_user(User $a, User $b) {
 		if($a->is_anonymous()) {
 			$this->theme->display_error(401, "Error", "You aren't logged in");
+			return false;
 		}
-		if($a->name == $b->name) {
+
+		if(
+			($a->name == $b->name) ||
+			($b->can("protected") && $a->class->name == "admin") ||
+			(!$b->can("protected") && $a->can("edit_user_info"))
+		) {
 			return true;
 		}
-		if($b->can("protected")) {
-			if($a->class->name == "admin") {
-				return true;
-			}
-			else {
-				$this->theme->display_error(401, "Error", "You need to be an admin to change other people's details");
-			}
-		}
 		else {
-			if($a->can("edit_user_info")) {
-				return true;
-			}
-			else {
-				$this->theme->display_error(401, "Error", "You need to be an admin to change other people's details");
-			}
+			$this->theme->display_error(401, "Error", "You need to be an admin to change other people's details");
+			return false;
 		}
-		return false;
 	}
 
 	private function redirect_to_user(User $duser) {