most functions working
merged working functions