beautified ugly code