raphael implementation (somewhat buggy)