Fixed variable declarations and simplified arithmetic