adding new function
fixed causeys code