pretty code and bug fixes