add -main functionality