changed mode to enum according to Cory Hardman's comments