added all library functions and implemented timeout