optimized/cleaned solution 4 a bit