cleaned up code and added back some selection features