fixed bug giving error on server, added a little functionality