Created first version

Seems to work but needs improvement on open/close condition and order
depending on direction.