modified the functions to numpy