modularize a little bit
add x11 code