cleanup

optimized the code for consistency and readability