Some functions changes to make code more readable