added new function and some changes to the old