Merged functions, still not working properly