Initial implementation. Still need some work