added Darep suggested fixes