Two function has been sligthly refactored.