added and fixed some functionality