moved implementation to its own function