admin function added and some fixes in code