refactored a little bit ;)