cleaned up bounds calculation