added more typing to function