funtion to work