Fixed a bug. Now it seems to work correctly!