recombined if/else statements, fixed rotation checking for angles close to +/-180