Added input conditions for all functions