Changed to use already existing code