insert function not working