final answer, not yet refactored. Works
refactored, removed unneccessary regexp