#UPDATE beautify the code a bit