changing input variable to int works - and tidied up previous method